﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master"
    Inherits="System.Web.Mvc.ViewPage<Dto.ManageMenuDto>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="iLocation">
        当前位置：数据管理 &raquo; 创建/编辑菜单项
    </div>
    <div class="content">
        <h1>
            创建/编辑菜单：</h1>
        <%
            using (Html.BeginForm("SaveMenu", "ManageMenu"))
            {%>
        <table class="addData">
            <caption>
                <h2>
                    后台菜单管理
                </h2>
            </caption>
            <tr class="tr2">
                <td class="alignR labelTxt">
                    <span class="redTxt">*</span>上级菜单
                </td>
                <td>
                    <%
                List<ManageMenuDto> menuList = ViewData["MenuList"] as List<ManageMenuDto> ?? new List<ManageMenuDto>();%>
                    <select name="MenuSuperiorId" id="MenuSuperiorId">
                        <option value="0">录于顶级</option>
                        <%
                foreach (ManageMenuDto menu in menuList)
                {%>
                        <option value="<%=menu.MenuID%>">
                            <%=menu.MenuName%></option>
                        <%
                    foreach (ManageMenuDto childMenu in menu.ChildMenuList ?? new List<ManageMenuDto>())
                    {%>
                        <option value="<%=childMenu.MenuID%>">┣<%=childMenu.MenuName%></option>
                        <%
                        foreach (ManageMenuDto lastMenu in childMenu.ChildMenuList ?? new List<ManageMenuDto>())
                        {%>
                        <option value="<%=lastMenu.MenuID%>">┣┣<%=lastMenu.MenuName%></option>
                        <%
                        }%>
                        <%
                    }%>
                        <%
                }%>
                    </select>
                    <%=Html.ActionLink("编辑", "EditMenu", new {Controller = "Manage"},
                                                  new {href = "javascript:Edit();"})%>
                    <%=Html.ActionLink("删除", "DeleteMenu", new {Controller = "Manage"})%>
                </td>
            </tr>
            <tr class="tr2">
                <td class="alignR labelTxt">
                    <span class="redTxt">*</span>菜单名称
                </td>
                <td>
                    <input class="tagInput" type="text" name="MenuName" id="MenuName" value="<%=Model.MenuName%>" />
                    <input type="hidden" name="MenuID" value="<%=Model.MenuID%>" />
                    <input type="hidden" name="MenuOldKey" value="<%=Model.MenuKey%>" />
                </td>
            </tr>
            <tr class="tr2">
                <td class="alignR labelTxt">
                    <span class="redTxt">*</span>菜单键值
                </td>
                <td>
                    <input class="tagInput" type="text" name="MenuKey" id="MenuKey" value="<%=Model.MenuKey%>" />
                    <br />
                    <span class="grayTxt">必须是不与其他菜单键值重复的唯一值得！</span>
                </td>
            </tr>
            <tr class="tr2">
                <td class="alignR labelTxt">
                    <span class="redTxt">*</span>菜单路径
                </td>
                <td>
                    <input class="tagInput" type="text" name="MenuPath" id="MenuPath" value="<%=Model.MenuPath%>" />
                    <br />
                    <span class="grayTxt">没有则不需填写</span>
                </td>
            </tr>
            <tr class="tr2">
                <td class="alignR labelTxt">
                    <span class="redTxt">*</span>排序
                </td>
                <td>
                    <input class="tagInput" type="text" name="MenuOrder" id="MenuOrder" value="<%=Model.MenuOrder%>" />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <label>
                        <input type="submit" name="button" value="保存" />
                    </label>
                </td>
            </tr>
        </table>
        <%
            }%>
    </div>
    <script type="text/javascript">
        function Edit() {
            location.href = '/Manage/EditMenu/' + $("#MenuSuperiorId").val();
        }

        function Delete() {
            location.href = '/Manage/DeleteMenu/' + $("#MenuSuperiorId").val();
        }
    </script>
</asp:Content>
